package top.weiliang.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.weiliang.springboot3.base.PageBean;
import top.weiliang.springboot3.base.R;

import top.weiliang.springboot3.entity.TbClass;
import top.weiliang.springboot3.entity.TbSoftwareType;
import top.weiliang.springboot3.service.TbSoftwareTypeService;
import top.weiliang.springboot3.vo.PageVO;

import java.util.List;

@RestController
@RequestMapping("/softwaretype")
@RequiredArgsConstructor
public class TbSoftwareTypeController {
    private final TbSoftwareTypeService tbSoftwareTypeService;


    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbSoftwareType>> queryPage(@PathVariable("pn")Long pageNumber,@PathVariable("ps") Long pageSize, TbSoftwareType tbSoftwareType){
        return tbSoftwareTypeService.queryPage(PageBean.instance(pageNumber,pageSize) ,tbSoftwareType);
    }



    @PostMapping("")
    @ResponseBody
    public R<String> insert(@RequestBody TbSoftwareType tbSoftwareType) { return tbSoftwareTypeService.insert(tbSoftwareType); }

    @GetMapping
    public R<List<TbSoftwareType>>query(TbSoftwareType tbSoftwareType){
        return tbSoftwareTypeService.query(tbSoftwareType);
    }

    @GetMapping("/{id}")
    public R<TbSoftwareType>queryById(@PathVariable("id") Integer id){

        return tbSoftwareTypeService.queryById(id);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbSoftwareType tbSoftwareType){
        return tbSoftwareTypeService.update(tbSoftwareType);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id){
        return tbSoftwareTypeService.delete(id);
    }


}
